// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/accesscontrol/api/AccessControlPointApi'

import OneClass from '@api/accesscontrol/model/AccessControlPointDto'
import StatusClass from '@api/accesscontrol/model/AccessControlPointDoorStatusReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 单项 —————————————————————————————— //

  async getOne({ id }, TIP = '查询门禁详情') {
    const DTO = CORE.grpcDTO(OneClass, { id })
    const resp = await CORE.grpc(TIP, CLIENT, 'accessControlPointQueryOne', DTO)
    const { accessControlPointDto, alarmDtos, bindDevice } = resp
    return { ...accessControlPointDto, alarmDtos, bindDevice }
  },

  // —————————————————————————————— 单项 —————————————————————————————— //

  async getStatus({ id }, TIP = '查询门禁状态') {
    const DTO = CORE.grpcDTO(StatusClass, { pointId: id })
    const resp = await CORE.grpc(TIP, CLIENT, 'accessControlPointDoorStatus', DTO)
    return resp.doorStatus
  },
}
